<?php
namespace app\admin\middleware;

use app\Request;
use think\Response;

class Auth {

    public function handle(Request $request, \Closure $next) :Response {
        // 前置中间件
        $path = $request->pathinfo();
        if (!isAdminLogin() && !preg_match("/(login|verify_code)/", $path)) {
            return redirect(url("login/index"));
        }else if (isAdminLogin() && preg_match("/login/", $path)){
            return redirect(url("index"));
        }
        $response = $next($request);
        //后置中间件


        return $response;
    }
}